package com.ronds.webtest.util;

import org.ehcache.Cache;
import org.ehcache.CacheManager;
import org.ehcache.config.builders.CacheConfigurationBuilder;
import org.ehcache.config.builders.CacheManagerBuilder;
import org.ehcache.config.builders.ResourcePoolsBuilder;

/**
 * Created by zhanghui on 2017/3/21.
 * 设置、获取properties中数据
 */
public class CacheUtil {

    private static CacheManager cacheManager;
    private static Cache<String, Object> cache;

    static {
        cacheManager = CacheManagerBuilder.newCacheManagerBuilder().build();
        cacheManager.init();
        cache = cacheManager.createCache("cache",
            CacheConfigurationBuilder.newCacheConfigurationBuilder(String.class, Object.class,
                ResourcePoolsBuilder.heap(10)).build());
    }

    public static void put(String key, Object value) {
        cache.put(key, value);
    }

    public static Object get(String key) {
        return cache.get(key);
    }

}
